//导入vue-router
import { createRouter,createWebHistory } from "vue-router";

//导入组件
import LoginVue from '@/views/Login.vue';
import LayoutVue from '@/views/Layout.vue';
import ArticleCategoryVue from '@/views/article/ArticleCategory.vue'
import ArticleManageVue from '@/views/article/ArticleManage.vue'
import ArticlePublish from '@/views/article/ArticlePublish.vue'
import ArticleSearch from '@/views/article/ArticleSearch.vue'
import CheckArticle from '@/views/editor/CheckArticle.vue'
import editorArticleSearch from '@/views/editor/EditorArticleSearch.vue'
import adminSearch from '@/views/admin/UserSearch.vue'
import UserAvatarVue from '@/views/user/UserAvatar.vue'
import UserInfoVue from '@/views/user/UserInfo.vue'
import UserResetPasswordVue from '@/views/user/UserResetPassword.vue'
import AdminLayoutVue from '@/views/AdminLayout.vue';
import EditorLayoutVue from '@/views/EditorLayout.vue';
import AdminArticleSearch from '@/views/admin/AdminArticleSearch.vue'
import editorSearch from '@/views/admin/EditorSearch.vue'
 
//定义路由关系，里面含有两个js对象
const routes = [
    //路径，访问组件
    {path:'/login', component : LoginVue},
    {path: '/', component: LayoutVue,redirect:'/article/manage',
    children:[
        {path: '/article/category',component:ArticleCategoryVue},
        {path: '/article/manage', component: ArticleManageVue},
        {path: '/article/publish', component: ArticlePublish},
        {path: '/article/search', component: ArticleSearch},
        {path: '/article/editorCheckArticle', component: CheckArticle},
        {path: '/user/avatar', component: UserAvatarVue},
        {path: '/user/info', component: UserInfoVue},
        {path: '/user/resetPassword', component: UserResetPasswordVue}
    ]
},
    {path: '/editor', component: EditorLayoutVue, redirect:'/editor/articleSearch',
    children:[
        {path: '/editor/articleSearch', component: editorArticleSearch},
        {path: '/editor/checkArticle', component: CheckArticle},
        {path: '/editor/avatar', component: UserAvatarVue},
        {path: '/editor/info', component: UserInfoVue},
        {path: '/editor/resetPassword', component: UserResetPasswordVue}
    ]
},
{path: '/admin', component: AdminLayoutVue,redirect:'/admin/userSearch',
children:[
    {path: '/admin/category',component:ArticleCategoryVue},
    {path: '/admin/userSearch', component: adminSearch},
    {path: '/admin/editorSearch', component: editorSearch},

    {path: '/admin/articleSearch', component: AdminArticleSearch},
    {path: '/admin/avatar', component: UserAvatarVue},
    {path: '/admin/info', component: UserInfoVue},
    {path: '/admin/resetPassword', component: UserResetPasswordVue}
]
},
]

//创建路由器
const router = createRouter({
    history: createWebHistory(),
    routes: routes
});

export default router;